﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnlineCellphoneStore
{
    public partial class Convert : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString.Count > 0)
            {
                // Required to keep the page from being cached on the client's browser
                Response.Expires = -1;
                Response.ContentType = "text/plain";
                if (Request.QueryString["get"] == "amount")
                {
                    string TotalAmount = Session["TotalAmount"].ToString();
                    Response.Write(TotalAmount);
                }
                else
                {
                    double Amount = Double.Parse(Request.QueryString["amount"].ToString());
                    double Rate = 3.85;
                    double Ans = 0;
                    if (Request.QueryString["from"] == "nis" && Request.QueryString["to"] == "usd")
                    {
                        Ans = Amount / Rate;
                        Response.Write(Ans.ToString());
                        Session["Currency"] = "USD";
                    }
                    else if (Request.QueryString["from"] == "usd" && Request.QueryString["to"] == "nis")
                    {
                        Ans = Amount * Rate;
                        Response.Write(Ans.ToString());
                        Session["Currency"] = "NIS";
                    }
                    Session["AmountToBuy"] = Ans;
                }
                Response.End();
            }
        }
    }
}